package com.ruoyi.performance.service.impl;

import com.ruoyi.common.core.text.Convert;
import com.ruoyi.performance.domain.PerfGroup2DTarget;
import com.ruoyi.performance.mapper.PerfGroup2DTargetMapper;
import com.ruoyi.performance.service.PerfGroup2DTargetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@Service
public class PerfGroup2DTargetServiceImpl implements PerfGroup2DTargetService {
    @Autowired
    PerfGroup2DTargetMapper perfGroup2DTargetMapper;

    @Override
    public List<PerfGroup2DTarget> selectPerfGroup2DTargetById(Long id){
        return perfGroup2DTargetMapper.selectPerfGroup2DTargetById(id);
    }

    @Override
    public List<PerfGroup2DTarget> selectPerfGroup2DTargetByCompanycode(String Companycode){
        return perfGroup2DTargetMapper.selectPerfGroup2DTargetByCompanycode(Companycode);
    }

    @Override
    public List<PerfGroup2DTarget> selectPerfGroup2DTargetList(PerfGroup2DTarget perfGroup2DTarget){
        return perfGroup2DTargetMapper.selectPerfGroup2DTargetList(perfGroup2DTarget);
    }

    @Override
    public List<PerfGroup2DTarget> selectPerfGroup2DTargetByGroupcode(String groupcode){
        return perfGroup2DTargetMapper.selectPerfGroup2DTargetByGroupcode(groupcode);
    }

    @Override
    public List<PerfGroup2DTarget> selectPerfGroup2DTargetByDetailtargetcode(String detailtargetcode){
        return perfGroup2DTargetMapper.selectPerfGroup2DTargetByDetailtargetcode(detailtargetcode);
    }

    @Override
    public int insertPerfGroup2DTarget(PerfGroup2DTarget perfGroup2DTarget){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
//        perfGroup2DTarget.setCreatedate(date);
//        perfGroup2DTarget.setCreatetime(time);
        return perfGroup2DTargetMapper.insertPerfGroup2DTarget(perfGroup2DTarget);
    }

    @Override
    public int updatePerfGroup2Dtarget(PerfGroup2DTarget perfGroup2DTarget){
        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
//        perfGroup2DTarget.setCreatetime(time);
//        perfGroup2DTarget.setCreatedate(date);
        return perfGroup2DTargetMapper.updatePerfGroup2DTarget(perfGroup2DTarget);
    }

//    @Override
//    public int deletePerfGroup2Dtarget(PerfGroup2DTarget perfGroup2DTarget){
//        String date = new SimpleDateFormat("yyyy-mm-dd").format(new Date());
//        String time = new SimpleDateFormat("hh-mm-ss").format(System.currentTimeMillis());
//        perfGroup2DTarget.setCreatedate(date);
//        perfGroup2DTarget.setCreatetime(time);
//        return perfGroup2DTargetMapper.deletePerfGroup2DTarget(perfGroup2DTarget);
//    }

    @Override
    public int deletePerfGroup2DtargetById(String id){
        return perfGroup2DTargetMapper.deletePerfGroup2DTargetById(Convert.toStrArray(id));
    }
}
